<template>
	<view>
		<view class="content">
			<view class="content_item" style="margin-bottom: 50rpx;">
				<view class="" style="color: red;">提示：创建诊所后，直接返回登录诊疗->下单即可（该诊所仅为演示使用下单不会产生收益）</view>
			</view>
			<view class="content_item">
				<view class="lefttext">诊所名称</view>
				<view class="">
					<input v-model="form.name" type="text" placeholder="请输入诊所名称" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="content_item">
				<view class="lefttext">负责人</view>
				<view class="">
					<input v-model="form.user" type="text" placeholder="请输入负责人" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="tips">
				手机号请填写本机可一键登录手机号
			</view>
			<view class="content_item">
				<view class="lefttext">负责人电话</view>
				<view class="">
					<input v-model="form.user_phone" type="text" placeholder="请输入负责人电话" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="content_item">
				<view class="lefttext">设备编号</view>
				<view class="">
					<input v-model="form.device_no_number" type="text" placeholder="请输入设备编号" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="content_item">
				<view class="lefttext">设备备注</view>
				<view class="">
					<input v-model="form.device_title" type="text" placeholder="请输入设备备注" />
				</view>
			</view>
			<view class="btns" @click="saveclinic">
				保存诊所
			</view>
			<!-- <view class="xian"></view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					id:'',
					name:'', // 诊所名称
					user:'', // 负责人
					user_phone:'', // 负责人电话
					device_id:'',
					device_no_number:'', // 设备编号
					device_title:'', // 设备标题
				}
			}
		},
		onLoad() {
			this.get_clinic()
		},
		methods: {
			get_clinic(){
				let that = this
				uni.request({
				    url: that.global.url + 'api/clinic/get_clinic',
				    method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
				    data: {},
				    success(res) {
				        let result = res.data
						console.log(result)
				        if(result.code == 1){
							that.form.id = result.data.id
							that.form.name = result.data.name
							that.form.device_id = result.data.device_id
							that.form.user = result.data.user
							that.form.user_phone = result.data.user_phone
							that.form.device_no_number = result.data.no_number
							that.form.device_title = result.data.title
						}else{
				           uni.showToast({
				           	title: result.msg,
				           	icon: 'error'
				           })
				        }
				       
				    }
				})
			},
			saveclinic(){
				let that = this
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
				    url: that.global.url + 'api/clinic/temporary_clinic',
				    method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
				    data: this.form,
				    success(res) {
				        let result = res.data
						console.log(result)
				        if(result.code == 1){
							uni.showToast({
								title: result.msg,
								icon: 'success'
							})
							that.get_clinic()
						}else{
				           uni.showToast({
				           	title: result.msg,
				           	icon: 'error'
				           })
				        }
				       
				    },complete() {
				    	uni.hideLoading()
				    }
				})
			}
		}
	}
</script>

<style>
.content{
	width: 85%;
	padding: 30rpx;
	border: 1px solid #ccc;
	border-radius: 10rpx;
	margin: 0px auto;
	margin-top: 30rpx;
}
.content_item{
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	/* border-radius: 1px solid #ccc; */
	border-radius: 10rpx;
	padding: 10rpx;
	margin-bottom: 10rpx 0rpx 10rpx 0rpx;
}
.xian{
	border-bottom: 1px solid #ccc;
}
.lefttext{
	width: 40%;
}
.btns{
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20rpx;
	
	background-color: #1262DB;
	color: #fff;
	margin: 0px auto;
	border-radius: 15rpx;
	margin-top: 30rpx;
}
.tips{
	    color: red;
	    font-size: 28rpx;
	    margin-left: 10rpx;
	    margin-top: 20rpx;
}
</style>
